package com.ep.tag;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class BaseTag extends TagSupport  {
	/**
	 * 输出流
	 */
	private JspWriter writer;
	private String url="";
	@Override
	public int doStartTag() throws JspException {
		this.writer=pageContext.getOut();
		HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
		String path = request.getContextPath();
		String serverlPath=request.getServletPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+serverlPath;
		/*url="<div style=\"display:none;\">"+ basePath+"</div>";*/
		url="<div style=\"display:none;\">"+ serverlPath+"</div>";
		return super.doStartTag();
	}
	@Override
	public int doEndTag() throws JspException {
			try {
				writer.write(url);
			} catch (IOException e) {
				e.printStackTrace();
			}
	        return EVAL_PAGE;
	}
	@Override
	public void release() {
		super.release();
	}
	public JspWriter getWriter() {
		return writer;
	}
	public void setWriter(JspWriter writer) {
		this.writer = writer;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
}
